home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 14157 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: nntp.teleport.com!usenet
  2. From: GHouck <hksys@teleport.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Character string
  5. Date: 12 Apr 1996 03:41:16 GMT
  6. Organization: systems hk
  7. Message-ID: <4kkjcs$c32@nadine.teleport.com>
  8. References: <4kil74$8i7@Tandem1.opennet.net.au> <4kja1d$7fm@spanky.pls.ov.com>
  9. NNTP-Posting-Host: ip-pdx08-22.teleport.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.22 (Windows; I; 32bit)
  14.  
  15. glenn@ov.com (Fletcher.Glenn@ov.com) wrote:
  16. >>How do I do a similar statement in C to the Pascal code:
  17. >>
  18. >>If Ch IN ['a','A'] THEN
  19. >>
  20. >>I know I can use if (ch=='a') && (ch=='A') but was looking for something
  21. >>a little more ellegant.
  22. >>
  23. >
  24. >For small tests (like two characters) you cannot beat the if test.  For
  25. >filtering among many characters, the code can be made much more understandable
  26. >using the switch() statement.  switch() allows you to identify various
  27. >responses to input values on a case by case basis.  See your local C book.
  28. >
  29.  
  30. Ken,
  31. Also, if what you're interested in is accommodating the upper and lower
  32. case characters at same time, how about using:
  33.  
  34.   if( toupper(ch) == 'A' ) {
  35.  
  36.   or
  37.   
  38.   switch( toupper(ch) ) {
  39.  
  40. Yours, Geoff Houck
  41.  
  42.